<script>
    // bind实现原理
    ; (function () {
        function mlbind(context) {
            let bindArgs = Array.prototype.slice.call(arguments, 1);
            // this 表示fn  this()不OK
            let that = this;
            function gn() {
                let args = Array.prototype.slice.call(arguments);
                return that.apply(context, bindArgs.concat(args))
            }
            return gn;
        }
        Function.prototype.mlbind = mlbind;
    })()
    function fn(num1, num2) {
        console.log(this);
        return num1 + num2;
    }
    let obj = { name: "码路" }
    // 1）改变fn中this的指向
    // 2）返回一个绑定this后的函数
    // let res = fn.bind(obj, 1)
    let res = fn.mlbind(obj, 1)
    console.log(res(2));
</script>